/*
 * @Autor: Ruohong Yu
 * @Date: 2023-04-18 21:37:26
 * @Description: file content
 * @FilePath: \ebook\src\utils\crypto.js
 */
import CryptoJS from 'crypto-js'
const key = CryptoJS.enc.Utf8.parse('ybookreaderforme')
export default {
  // 加密
  Encrypt (word) {
    const srcs = CryptoJS.enc.Utf8.parse(word)
    const encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
    return encrypted.toString()
  },
  // 解密
  Decrypt (word) {
    const decrypt = CryptoJS.AES.decrypt(word, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
    const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8)
    return decryptedStr.toString()
  }
}
